comment intégrer correctement un assistant AI Telnyx via TeXML

22:15


To integrate a Telnyx AI Assistant via TeXML, follow these steps:

Configuration of the AI Assistant with TeXML
1. Create a TeXML Application
Log in to the Telnyx portal.
Navigate to the "Applications" section.
Create a new application of type "TeXML".
Set up the webhook URL where Telnyx will send HTTP requests to retrieve TeXML instructions.
2. Configure Your AI Assistant
Go to the AI Assistants↗ tab in the Telnyx portal.
Create a new assistant with your custom instructions.
Configure voice parameters (voice, speed).
Enable the agent for calls.
3. Integrate the Assistant into Your TeXML
Use the <AIGather> verb with the following elements:

xml


<Response>
    <AIGather action="/after_ai_gather">
        <Greeting>Message d'accueil pour l'appelant</Greeting>
        <Parameters>
            <![CDATA[
            {
                "properties": {
                    "age": {
                        "description": "L'âge du client",
                        "type": "integer"
                    },
                    "location": {
                        "description": "La localisation du client",
                        "type": "string"
                    }
                },
                "required": ["age", "location"],
                "type": "object"
            }
            ]]>
        </Parameters>
        <Voice name="Telnyx.NaturalHD.Astra" voice_speed="1.0"/>
        <MessageHistory>
            <Message role="user">Bonjour, je m'appelle Jean.</Message>
        </MessageHistory>
        <Assistant model="openai/gpt-4" api_key_ref="my_key_ref" instructions="Vous êtes un assistant utile qui peut aider le client avec ses questions.">
            <Tools>
                <Tool>
                    <![CDATA[
                    {
                        "type": "hangup",
                        "hangup": {
                            "description": "Raccrocher l'appel."
                        }
                    }
                    ]]>
                </Tool>
                <Tool>
                    <![CDATA[
                    {
                        "type": "transfer",
                        "transfer": [
                            {
                                "name": "support",
                                "to": "+1234567890"
                            }
                        ]
                    }
                    ]]>
                </Tool>
            </Tools>
        </Assistant>
    </AIGather>
</Response>
Key Elements of <AIGather>
Attributes:

action: URL where TeXML will send collected data.
method: HTTP request type (GET or POST).
Child Elements:

<Greeting>: Initial message for the caller.
<Voice>: Voice configuration (name, speed).
<Parameters>: JSON schema of parameters to collect.
<MessageHistory>: Message history for context.
<Assistant>: AI model configuration (model, api_key_ref, instructions).
<Tools>: Available tools for the assistant (e.g., hangup, transfer).
API Key Configuration
OpenAI:

Create an OpenAI API key.
Reference it in the api_key_ref attribute of the <Assistant> element.
Use a model like openai/gpt-4.
ElevenLabs (Voice):

Create an ElevenLabs API key.
Reference it in the api_key_ref attribute of the <Voice> element.
Documentation Resources
TeXML Verbs: AIGather↗
Voice Assistant Quickstart↗
TeXML Fundamentals↗
Creating a TeXML Application↗
Important Points
Ensure your webhook URL is publicly accessible and uses HTTPS.
Test your assistant in the portal before integration.
Use integrated tools (Webhook, Handoff, Transfer, Send DTMF) to enhance your assistant's capabilities.
Check conversation history in the Conversation History tab for debugging.
For further configuration assistance, refer to the provided documentation links.