XML Descriptions for Integration Template
Yeastar P-Series Cloud Edition allows you to create CRM/Helpdesk integration templates, where you can define the necessary settings, including specific API endpoints, data fields, and functional scenarios required for the integration. This topic provides detailed description of the setting elements in the XML templates.
Template conventions
The template follows the XML 1.1 standard specification. This section describes the syntax and conventions of the template.
- Variable
- The template supports the use of variables for dynamic data. When the template is executed, the variables referenced within the template will be replaced with their respective values.
- Function
- The template supports the following function, which can be used in
conjunction with variables to dynamically manipulating or formatting the
variable value.
Function Description TimeFormat The function can be used to customize the format of a timestamp. Format: {{ TimeFormat Timestamp_variable "format_string" "Whether_to_convert_to_UTC_time" }}
Example:
{{ TimeFormat .StartTimeUnix "yyyy-MM-ddTHH:mm:ss.000Zz" "1" }}Assuming the value of {{.StartTimeUnix}} is
1672531199, the final output would be2023-01-01T00:59:59.000Z.ToMillis The function can be used to convert a seconds timestamp to a milliseconds timestamp. Format: {{ ToMillis Timestamp_variable}}
Example:
{{ ToMillis .StartTimeUnix }}Assuming the value of {{.StartTimeUnix}} is
1672531199, the final output would be1672531199000.Capitalize The function can be used to capitalizes the first letter of a string. Format: {{ Capitalize variable_string}}
Example:
{{ Capitalize .variable_string }}Assuming the value of {{.variable_string}} is
hello world, the final output would beHello world.UrlEncode The function can be used to URL encode a string. Format: {{ UrlEncode .variable }}
Example:
{{ UrlEncode .variable}}Assuming the value of {{.variable_string}} is
hello world!, the final output would behello%20world%21. - Elements
- The templates offers the following main elements that help define the integration interactions, ensuring that the template can seamlessly connect with the third-party system and process data based on integration requirements.
Template property
The <Information> element provides the properties of the
template, including the basic template information and configuration overview, as
listed below:
| Attribute | Description |
|---|---|
| Provider | The type of the template, with a fixed value of
crm or helpdesk. |
| Name | The name of the template. |
| Key | Unique identifier for the template. |
| Logo | The filename of the logo. |
| Remark | A description or remark about the template. |
| Version | The version of the template. E.g.
1.0.0. |
| AuthType | The authentication method used in the integration.
|
| MaxConcurrentRequest | The maximum number of concurrent HTTP requests allowed to the CRM/Helpdesk. |
| UserAssociation | Whether the User Association feature is enabled or not.
|
| CallJournal | Whether the Call Journal feature is enabled or not.
|
| CreateNewContact | Whether the Create New Contact feature is enabled or not.
|
| CreateNewTicket | Whether the Create New Ticket Automatically feature is
enabled or not.
|
Authentication scenario
This scenario defines the authentication method used by the CRM/Helpdesk system. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="AuthMethod" Type="AUTH">
<Presets></Presets>
<Parameters>
<Parameter Name="AuthMethod" Value="oauth2"></Parameter>
<Parameter Name="AuthEndPoint" Value="https://api.example.com/oauth/v2/auth?client_id={{.client_id}}"></Parameter>
<Parameter Name="TokenEndPoint" Value="https://api.example.com/oauth/v2/token?client_id={{.client_id}}&client_secret={{.client_secret}}"></Parameter>
<Parameter Name="ContentType" Value="application/json"></Parameter>
<Parameter Name="AdditionalQueryString"></Parameter>
<Parameter Name="Scope" Value="contacts.read,contacts.write,calls.read,calls.write,user.read,user.write"></Parameter>
<Parameter Name="CredentialType"></Parameter>
<Parameter Name="Base64EncodedCredential"></Parameter>
<Parameter Name="TokenRefreshInterval" Value="25"></Parameter>
<Parameter Name="TokenRefreshBody" Value="grant_type=refresh_token&refresh_token={{.refresh_token}}"></Parameter>
<Parameter Name="TokenRefreshEndpointMethod" Value="post"></Parameter>
<Parameter Name="TokenRefreshEndpoint" Value="https://api.example.com/oauth2/token"></Parameter>
<Parameter Name="TokenRefreshContentType" Value="application/x-www-form-urlencoded"></Parameter>
<Parameter Father="CustomFieldList" Name="client_id" Editor="password" Title="Client ID"></Parameter>
<Parameter Father="CustomFieldList" Name="client_secret" Editor="password" Title="Client Secret"></Parameter>
<Parameter Father="PopulateTemplateString" Name="Content-Type" Type="Header" Value="application/json" Description="The format of the request body"/>
<Parameter Father="PopulateTemplateString" Name="Accept" Type="Header" Value="application/json" Description="The expected response data format from the server "/>
<Parameter Father="PopulateTemplateString" Name="X-CSRF-Token" Type="Header" Value="f3e1a2b4c5d6e7f8g9h0" Description="Prevent Cross-Site Request Forgery (CSRF) attacks"/>
<Parameter Father="PopulateTemplateString" Name="X-Client-Id" Type="Header" Value="{{.client_id}}" Description="for client identification"/>
<Parameter Father="FollowUpList" Name="ffb425cb-565d-49cd-92be-3290d0ab5129" Type="FollowUpRequest" Value="" IsDelete="0">
<Parameter Name="TriggeredEvent" Value="token_retrieved"></Parameter>
<Parameter Name="RequestMethod" Value="post"></Parameter>
<Parameter Name="Url" Value="https://api.example.com/v1/install/verify"></Parameter>
<Parameter Name="Headers" Value="{"Content-Type":"application/json","X-Request-ID": "550e8400-e29b-41d4-a716-446655440000","User-Agent":"YourApp-Integration/1.0.0"}"></Parameter>
<Parameter Name="Body" Value="{"app_id":"your_unique_app_identifier","webhook_url":"https://your-app.com/api/webhooks"}"></Parameter>
<Parameter Name="ResponseFieldPath" Value="$.data.access_token, $.tokens[0].value"></Parameter>
<Parameter Name="TargetVariable" Value="token,refresh"></Parameter>
</Parameter>
</Parameters>
<Requests></Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Parameter element
-
Attribute Description Name The name of the authentication setting. Value The value of the authentication setting. Father The name of parent parameters. The authentication scenario includes three parent parameter types, each serving as a container to organize related child parameters into distinct setting groups.CustomFieldList: Defines a set of fields for users to input authentication credentials (e.g., Client ID, Client Secret) in the configuration UI.Note: The variables captured in the custom fields are accessible for all the subsequent requests in the template.PopulateTemplateString: Defines custom HTTP headers to be included in every predefined CRM / Helpdesk synchronization requests (e.g., user association, contact synchronization. etc.) sent to the CRM/Helpdesk system.FollowUpList: Defines one or more automated API requests that are triggered after a specific event, such as after a token is successfully retrieved.
User association scenario
This scenarios is used to retrieve the list of users from the CRM/Helpdesk system. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="UserAssociation" Type="REST">
<Parameters></Parameters>
<Requests>
<Request Name="UserAssociation" Method="GET" ResponseType="application/json" RequestEncoding="" URLFormat="https://www.api.example.com/v1/users?type=ActiveUsers">
<Parameters>
<Parameter Name="PaginationEnabled" Value="0" />
<Parameter Name="PaginationType" Value="" />
<Parameter Name="VarPageName" Value="page" />
<Parameter Name="VarPageValue" Value="1" />
<Parameter Name="VarPageSizeName" Value="page_size" />
<Parameter Name="VarPageSizeValue" Value="10" />
<Parameter Name="VarOffsetName" Value="from" />
<Parameter Name="VarOffsetValue" Value="1" />
<Parameter Name="VarLimitName" Value="limit" />
<Parameter Name="VarLimitValue" Value="10" />
<Parameter Name="VarNextPagePath" Value="links.next" />
</Parameters>
<Outputs>
<Output Name="UserUniqueId" Path="users.#.id" Type=""></Output>
<Output Name="FirstName" Path="users.#.First_Name" Type=""></Output>
<Output Name="LastName" Path="users.#.Last_Name" Type=""></Output>
<Output Name="Email" Path="users.#.Email" Type=""></Output>
</Outputs>
</Request>
</Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Request element
- The
<Request>element has the following attributes:
- Parameter element
- The
<Parameter>element provides has the following attributes:Attribute Description Name The name of the pagination settings used in the scenario. Value The value of the pagination settings. Pagination settingsSetting Description PaginationEnabled Whether to enable pagination. Valid value:0: Disable.1: Enable.
PaginationType Specify the pagination mode. Valid value:page_based: Retrieve user data based on page number and page size.offset_based: Retrieve user data based on a starting index and record limit.link_based: Retrieve user data by using the URL pointing to the next page of data in the API response.
VarPageName Enter the parameter name used to specify the page number in API requests. Note: This parameter is only available forpage_basedpagination mode.VarPageValue Specify the initial page number from which to start querying data. Note: This parameter is only available forpage_basedpagination mode.VarPageSizeName Enter the parameter name used to specify the number of records per page in API requests. Note: This parameter is only available forpage_basedpagination mode.VarPageSizeValue Specify the maximum number of records to return in a single page. Note: This parameter is only available forpage_basedpagination mode.VarOffsetName Enter the parameter name used to specify the start position in API requests. Note: This parameter is only available foroffset_basedpagination mode.VarOffsetValue Specify the starting position for data retrieval by indicating the number of records to skip. For example, a value of
1starts from the first record, while100starts retrieval from the 100th record.Note: This parameter is only available foroffset_basedpagination mode.VarLimitName Enter the parameter name used to specify the number of records per page in API requests. Note: This parameter is only available foroffset_basedpagination mode.VarLimitValue Specify the maximum number of records to return in a single page. Note: This parameter is only available foroffset_basedpagination mode.VarNextPagePath Specify the JSON path (e.g. links.next) used to obtain the link pointing to the next page of data.Note: This parameter is only available forlink_basedmode.
- Output element
- The
<Output>element has the following attributes:
Automatic contact synchronization scenario
This scenarios is used to search for contacts in the CRM/Helpdesk system, and the returned information can be used to implement CRM contacts searching, automatic contact synchronization and call popup. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="SyncContactAuto" Type="REST">
<Presets></Presets>
<Parameters>
<Parameter Name="ContactUrlType" Value="retrieve_from_contact"></Parameter>
<Parameter Name="URLFormat"></Parameter>
<Parameter Name="ContactFieldForUri" Value="data.#.contactUrl"></Parameter>
<Parameter Name="ContactsIdEnable" Value="1"></Parameter>
<Parameter Name="FirstNameEnable" Value="1"></Parameter>
<Parameter Name="BusinessNumberEnable" Value="1"></Parameter>
<Parameter Name="CustomValueEnable" Value="0"></Parameter>
</Parameters>
<Requests>
<Request Name="Contacts" Method="GET" ResponseType="application/json" RequestEncoding="" URLFormat="https://www.api.example.com/v1/Contacts/search?criteria=((Phone:equals:{{.Phone}})or(Home_Phone:equals:{{.Phone}})or(Mobile:equals:{{.Phone}})or(Asst_Phone:equals:{{.Phone}}))">
<Parameters></Parameters>
<Outputs>
<Output Name="ContactsId" Path="data.#.id" Type=""></Output>
<Output Name="FirstName" Path="data.#.First_Name" Type=""></Output>
<Output Name="BusinessNumber" Path="data.#.Phone" Type=""></Output>
...
<Output Name="CustomValue" Path="data.#.Owner" Type=""></Output>
</Outputs>
</Request>
</Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Parameter element
- The
<Parameter>element provides has the following attributes: - Request element
- The
<Request>element has the following attributes:
- Output element
- The
<Output>element has the following attributes:
Automatic contact creation scenario
This scenarios is used to create a new contact in the CRM/Helpdesk system when the caller’s number does not match any existing contact. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="CreateNewContact" Type="REST">
<Parameters></Parameters>
<Requests>
<Request Name="Contacts" Method="POST" ResponseType="application/json" RequestEncoding="" URLFormat="https://www.api.example.com/v1/Contacts">
<Parameters>
<Parameter Name="Data" Type="Body" Value="{"data": [{"Last_Name":"{{.LastName}}","First_Name":"{{.FirstName}}","Phone":"{{.BusinessNumber}}";}]}"></Parameter>
</Parameters>
<Outputs></Outputs>
</Request>
</Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Request element
- The
<Request>element has the following attributes:
- Parameter element
- The
<Parameter>element nested within the<Request>element defines the parameters included in the request body.Attribute Description Name The name of the parameter, which should be fixed as Data.Type The type of the parameter, which should be fixed as Body.Value Defines the required parameters to be passed through the request body, within a datastructure. The parameter values can be retrieved from the pre-defined variables in the PBX system.Note: The format should follows XML parameter standards. For example, if a line break is required, you must use the escape character
to represent a newline.
Automatic ticket creation scenario (for Helpdesk system only)
This scenarios is used to create a new ticket in the Helpdesk system. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="CreateNewTicket" Type="REST" >
<Presets></Presets>
<Parameters>
<Parameter Name="EnableSubject" Value="1"></Parameter>
<Parameter Name="Subject" Value="{{.Communication_Type}} {{.Call_Status}} - from {{.Call_From}} to {{.Call_To}}"></Parameter>
<Parameter Name="EnableDescription" Value="1"></Parameter>
<Parameter Name="Description" Value="{{.Time}} {{.Communication_Type}} {{.Call_Status}} - from {{.Call_From}} to {{.Call_To}} {{.Talk_Duration}}"></Parameter>
</Parameters>
<Requests>
<Request Name="CreateNewTicket" Method="POST" Weight="0" ResponseType="application/json" RequestEncoding="" URLFormat="https://{{.domain}}/api/v1/tickets">
<Parameters>
<Parameter Name="Data" Type="Body" Value="{"subject":"{{.Subject}}","contactId":"{{.ContactId}}","phone":"{{.ContactNumber}}","description":"{{.Description}}";}"></Parameter>
</Parameters>
<Outputs></Outputs>
</Request>
</Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Parameter element
-
Attribute Description Name The name of the configuration settings used in the scenario. Value The value of the configuration settings. Configuration settingsSettings Description EnableSubject Whether to allow users to customize the subject of the ticket. Valid value:0: Disable.1: Enable.
Subject Specify the default value of the subject. Note: The default value is{{.Communication_Type}} {{.Call_Status}} - from {{.Call_From}} to {{.Call_To}}. For more supported variables, see the parameter variable list.EnableDescription Whether to allow users to customize the description of the ticket. Valid value:0: Disable.1: Enable.
Description Specify the default value of the description. Note: The default value is{{.Time}} {{.Communication_Type}} {{.Call_Status}} - from {{.Call_From}} to {{.Call_To}} {{.Talk_Duration}}. For more supported variables, see the parameter variable list. - Request element
- The
<Request>element has the following attributes:
- Parameter element
- The
<Parameter>element nested within the<Request>element defines the parameters included in the request body.Attribute Description Name The name of the parameter, which should be fixed as Data.Type The type of the parameter, which should be fixed as Body.Value Defines the required parameters to be passed through the request body. The parameter values can be retrieved from the pre-defined variables in the PBX system. Note: The format should follows XML parameter standards. For example, if a line break is required, you must use the escape character
to represent a newline.
Call journal scenario
This scenarios is used to log the call activities of associated users to the CRM / Helpdesk. The structure of the scenario and its key elements are outlined as below:
<Scenario Id="CallJournal" Type="REST">
<Presets></Presets>
<Parameters>
<Parameter Name="EnableSubject" Value="1"></Parameter>
<Parameter Name="Subject" Value="Extension Call"></Parameter>
<Parameter Name="EnableDescription" Value="1"></Parameter>
<Parameter Name="Description" Value="Call: {{.Time}} {{.Call_Log_Status}} from {{.Call_From}} to {{.Call_To}} {{.Talk_Duration}}"></Parameter>
<Parameter Name="EnablePlayCallRecording" Value="1"></Parameter>
<Parameter Name="PlayCallRecording" Value="0"></Parameter>
<Parameter Name="EnableForwardCallLogForAnsweredAgent" Value="0"></Parameter>
<Parameter Name="ForwardCallLogForAnsweredAgent" Value="0"></Parameter>
</Parameters>
<Requests>
<Request Name="CallJournal" Method="POST" Weight="0" ResponseType="application/json" RequestEncoding="" URLFormat="https://www.api.example.com/crm/v2/Calls">
<Parameters>
<Parameter Name="Data" Type="Body" Value="{"data"[{"{{.Owner}}{{.WhoModule}}": {"Description":"{{.Description}}","Voice_Recording__s":"{{.RecordPath}}","Call_Start_Time":"{{TimeFormat .StartTimeUnix "yyyy-MM-ddTHH:mm:ss-z" "1"}}","Subject&":"{{.Subject}}","Call_Type": "Inbound","Call_Result": "{{.Call_Log_Status}}","Call_Duration": "{{.Talk_Duration_Sec}}"}}]}"></Parameter>
</Parameters>
<Outputs></Outputs>
</Request>
</Requests>
</Scenario>
Here is a detailed explanation of the specific elements within the scenario.
- Scenario element
- The
<Scenario>element has the following attributes: - Parameter element
-
Attribute Description Name The name of the configuration settings used in the scenario. Value The value of the configuration settings. Configuration settingsSettings Description EnableSubject Whether to the call log subject is configurable in the integration. Valid value:0: Disable.1: Enable.
Subject Specify the default value of the subject. Note: The default value isExtension Call, you can also specify the subject using the supported variables.EnableDescription Whether to the call log description is configurable in the integration. Valid value:0: Disable.1: Enable.
Description Specify the default value of the description. Note: The default value is{{.Time}} {{.Communication_Type}} {{.Call_Status}} - from {{.Call_From}} to {{.Call_To}} {{.Talk_Duration}}. For more supported variables, see the parameter variable list.EnablePlayCallRecording Whether the feature to play call recordings within the CRM/Helpdesk is configurable in the integration. Valid value:0: Disable.1: Enable.
PlayCallRecording Specify the default status of the call recording playback option. Valid value:0: Disable.1: Enable.
EnableForwardCallLogForAnsweredAgent Whether the option to prevent logging missed calls for queue or ring group calls to non-answering agents' CRM/Helpdesk is configurable in the integration. ForwardCallLogForAnsweredAgent Specify the default status of the option to prevent logging missed calls for queue or ring group calls to non-answering agents' CRM/Helpdesk. Valid value:0: Disable.1: Enable. Call logs for queue and ring group calls are synchronized only to the CRM/Helpdesk of the agent who answered the call, while missed call logs for the same call are not synchronized to the CRM of agents who did not answer.
- Request element
- The
<Request>element has the following attributes:
- Parameter element
- The
<Parameter>element nested within the<Request>element defines the parameters included in the request body.Attribute Description Name The name of the parameter, which should be fixed as Data.Type The type of the parameter, which should be fixed as Body.Value Defines the required parameters to be passed through the request body. The parameter values can be retrieved from the pre-defined variables in the PBX system. Note: The format should follows XML parameter standards. For example, if a line break is required, you must use the escape character
to represent a newline.
Extended configurations
- Set custom request headers
- If custom request headers are needed, you can add parameter(s) with the
type set to
Header. This will add the headers to the request body. - Identify token errors
- In the
AuthMethodscenario, you can add a parameterTokenInvalidto help identify whether the issue in the request is related to the token or other underlying problems. - Retrieve additional variables for global use
- If you require additional variables beyond the provided ones, if you
want to use certain common information globally during the integration
process, you can define a
GetGlobalInfoscenario and set up the related requests to retrieve the necessary values. - Supplement contact query information
- If the initial query for contact information does not return all the necessary information you need, further queries may be required using the returned contact ID or other contact information.
- Retrieve TicketID for further operations
- In a Helpdesk integration template, you can configure additional settings to retrieve the ticket ID for subsequent operations, such as updating the ticket or referencing the variable in call journal.