https://retellai.com/?utm_source=discord&utm_medium=seo logo
How can I automate testing of my chatbot
# ❓・ai-evy-support
a
@AI Evy How can I automate testing of my chatbot? Are there any API's for that?
a
Thanks for tagging me @Adrian Mateos. I'll look through relevant sources and get back to you shortly.
### Answer You can automate testing of your chatbot using Retell AI's Create Chat API [(1) ]() . The API allows you to create chat sessions programmatically, which you can use for automated testing . Here's the JavaScript code to create a chat session:
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const chatResponse = await client.chat.create({ agent_id: 'oBeDLoLOeuAbiuaMFXRtDOLriTJ5tSxD' }) ;
console.log(chatResponse.agent_id) ;
The API returns comprehensive data about the chat session including the transcript, message history, chat analysis, and chat success status . This makes it suitable for automated testing scenarios where you need to verify agent responses and conversation flow . Additionally, the documentation mentions that you can simulate conversations and test through audio as well [(2) ](

▾

) . You can test the LLM and simulate conversations to verify the logic and flow transitions . For more comprehensive testing automation, you would typically create multiple chat sessions with different test scenarios and analyze the returned data to verify your chatbot's performance.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
​ To learn more, see the sources I considered: [[1] Create Chat](https://docs.retellai.com/api-references/create-chat) [[2] Personalization with Airtable](

https://www.youtube.com/watch?v=U8jdhkqOOhE▾

) ​
a
Can you provide the Python code?
@AI Evy Can you please provide the python code
a
Thanks for the follow-up, @Adrian Mateos. I'll get back to you soon.
### Answer Yes, here's the Python code to create a chat session for automated testing:
Copy code
python
from retell.types import ChatResponse, ChatListResponse, ChatCreateChatCompletionResponse
[(1) ]() To create a chat session, you can use the Python SDK with the following method:
Copy code
python
client.chat.create(**params) -> ChatResponse
The Python SDK provides several chat-related methods for automated testing : -
client.chat.create()
- Create a chat session -
client.chat.retrieve(chat_id)
- Retrieve chat details -
client.chat.list()
- List chat sessions -
client.chat.create_chat_completion(**params)
- Create chat completions -
client.chat.end(chat_id)
- End a chat session For comprehensive automated testing, you would create multiple chat sessions with different test scenarios and analyze the returned
ChatResponse
data to verify your chatbot's performance . The response includes transcript, message history, chat analysis, and success status - all useful for automated validation [(2) ]() .
​ To learn more, see the sources I considered: [[1] RetellAI/retell-python-sdk/api.md](https://github.com/RetellAI/retell-python-sdk/blob/main/api.md) [[2] Create Chat](https://docs.retellai.com/api-references/create-chat) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.