Botpress
Botpress is an open-source platform for building AI-powered chatbots and conversational agents with a visual workflow builder.
Prerequisites
A Botpress Cloud account (app.botpress.cloud)
Your TensorX API key from app.tensorx.ai
Configuration
Botpress uses the Execute Code card to make HTTP requests to external APIs like TensorX. This method gives you full control over the API integration.
Method: Execute Code Card
Step 1: Create a Workflow
Open your bot in Botpress Studio
Create a new workflow or open an existing one
Add a node where you want to call the AI
Step 2: Add Execute Code Card
Click + to add a new card
Select Execute Code
This opens the code editor
Step 3: Write the API Call
Step 4: Set Environment Variable
Go to Chatbot Settings → Variables
Add a new Secret variable named
TENSORX_API_KEYPaste your TensorX API key
Step 5: Display the Response
After the Execute Code card:
Add a Text card
Set the content to:
{{workflow.aiResponse}}
Building a Complete Chatbot
Basic AI Chatbot Flow
Start Node: Entry point of the conversation
Capture: Stores user message in
event.previewExecute Code: Calls TensorX API
Text Card: Shows the AI response
Multi-Turn Conversation
For conversations with memory:
Example Implementations
Customer Support Bot
Intent Classifier
Use AI to classify user intent:
Then use Expression transitions to route based on workflow.userIntent.
FAQ Bot with Knowledge Base
Model selection
Call GET /v1/models with your TensorX API key and use one of the returned IDs. If the integration depends on a capability or token limit, query GET /v1/model/info before selecting the model. See Models for examples.
Error Handling
Add try-catch for robust error handling:
Best Practices
1. Use Environment Variables
Never hardcode API keys. Use Botpress secrets:
env.TENSORX_API_KEY
2. Set Appropriate Timeouts
AI responses can take a few seconds. Set reasonable timeouts:
3. Limit Conversation History
For multi-turn conversations, limit history to prevent token overflow:
4. Handle Edge Cases
Empty user messages
Very long messages
API failures
Troubleshooting
"axios is not defined"
Axios is available globally in Botpress Execute Code. If you get this error:
Check for typos in
axiosEnsure you're using
awaitfor the API call
API Key Not Working
Verify the secret variable name matches:
env.TENSORX_API_KEYCheck the key at app.tensorx.ai
Ensure there are no extra spaces
Timeout Errors
Increase timeout value
Use a faster model
Reduce max_tokens for quicker responses
Response Not Displaying
Check the variable name:
workflow.aiResponseEnsure the Text card references
{{workflow.aiResponse}}Debug by logging:
console.log(response.data)
Support
Need help? Contact us at support@tensorx.ai
Last updated
Was this helpful?

