CRM Integration (Odoo) : Create Contact and LiveChat Log

Status
Not open for further replies.

Lop

Free User
Joined
Jun 30, 2023
Messages
21
Reaction score
9
Hi,

I'm doing a full integration between Odoo and 3CX. Working pretty fine for Search Contact by Email, Search Contact by Phone, Opening contact in Odoo when a call is answered...

Anyway, I don't understand when the Contact Creation and Livechat Log calls are supposed to be triggered.
I thought Livechat would happen when we close a chat, it's not the case,
I thought Contact Creation would happen when we send back no data or à 404 when searching a contact by Phone, but it's not.

Can you please give me a hint when / how to trigger those two calls ? :)
Once I know that I can finish the integration and will have a full Odoo/3CX Integration (with capabilities of CRM Integration Template).

PS: Reading the forum, it's sad there still isn't a full REST Api to control 3CX, it would be so so awesome ! Hope this will come at some point ^^

thanks alot in advance for your help !
Regards,
LOP
 
  • Like
Reactions: saasx
I thought Livechat would happen when we close a chat, it's not the case,
Chat Journaling is triggered when you click "Dealt with".

I thought Contact Creation would happen when we send back no data or à 404 when searching a contact by Phone, but it's not.
Up to 3CX v18 Update 7, contact creation will be triggered automatically when the contact lookup returns no results. Please note that a 404 response is considered an error (i.e. the web service endpoint was not found), and not an empty response. The service must return a 200 OK response, with an empty JSON as body.

Since 3CX v18 Update 8 (still in beta), contact creation is not happening automatically anymore, and you need to click "Add contact" from the Web Client / Desktop app in order to create it.
 
  • Like
Reactions: Lop and Evolute IT
Chat Journaling is triggered when you click "Dealt with".


Up to 3CX v18 Update 7, contact creation will be triggered automatically when the contact lookup returns no results. Please note that a 404 response is considered an error (i.e. the web service endpoint was not found), and not an empty response. The service must return a 200 OK response, with an empty JSON as body.

Since 3CX v18 Update 8 (still in beta), contact creation is not happening automatically anymore, and you need to click "Add contact" from the Web Client / Desktop app in order to create it.
Taking advantage of the colleague's doubt, there is not even a way for the Call Journing to happen before the call is closed, right? For example. For support to start customer service the moment the call takes place.
 
Taking advantage of the colleague's doubt, there is not even a way for the Call Journing to happen before the call is closed, right? For example. For support to start customer service the moment the call takes place.
No, call journaling is triggered when the call ends. However, if you're developing a custom integration, you can invoke your API when the call starts, the only "problem" here is that you will only have the phone number of the external party, not the agent that makes or receives the call.
 
  • Like
Reactions: Lop and Evolute IT
Hi @edossantos,

Thanks a lot for the quick answer.
The Contact Creation indeed works well when returning a 200 with empty data to the search.
Now for the LiveChat, I did try with the "Dealt With" but it looks like it doesn't work.

Steps I did:
- Create a new chat, that creates the customer in my Odoo
- Send some messages
- Click on Dealt With
-> No API Call to my Odoo
- Re-create a new chat, it finds the customer by email in my Odoo
- Send some messages again
- Close from the customer page
- Dealt With
-> No API Call to my Odoo

The CRM Integration "Enable Chat Journaling" is ON and I even tried by changing in the template that the only condition is that this button is ON to avoid any disturbance from other options.

If you have any clue or hint, thanks in advance sharing them :) (perhaps an option somewhere I should activate apart from the CRM Integration Template Enable Chat Journaling ?)

If need be, I can do a video to show you :)
 
In order to investigate the issue, please enable verbose logs from the 3CX Console > Dashboard > Activity Log > Settings. Then make a test chat where you reproduce the issue, and check the 3cxSystemService.log file that you can download from the 3CX Console > Dashboard > Activity Log > Logs button > Instance folder. In this file you will see all the interactions between 3CX and the CRM.
 
  • Like
Reactions: Lop
Ok thanks, so here is the thrown Exception:

2023/07/03 13:58:23.639|542|0096|Erro|CRM: Exception during chat reporting: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.ArgumentException: String cannot be of zero length. (Parameter 'oldValue')
at System.String.Replace(String oldValue, String newValue)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at TcxLexicalParser.LexEvaluator.Process(Element element, IValueManager valueManager, Boolean isFunctionArgument)
at CrmIntegration.EscapedExpressionEvaluator.ParseExpression(String expression, Boolean asExpression, IValueManager customManager)
at CrmIntegration.CrmIntegrationTemplateExtensions.Evaluate(RequestValue value, ProcessingContext context, IValueManager customManager)
at CrmIntegration.ScenarioProcessorBase.CreateJsonFromPostValues(RequestItem requestItem, IValueManager customManager)
at CrmIntegration.ScenarioProcessorBase.ProcessRequest(ScenarioRequest request, IValueManager customManager, HttpClient client, CancellationToken token)
at CrmIntegration.ScenarioProcessorBase.ProcessScenario(ProtocolScenario scenario, IValueManager customManager, CancellationToken token)
at CrmIntegration.ScenarioProcessorBase.Execute(ProtocolScenario scenario, CancellationToken token)
at CrmIntegration.CrmProcessor.ExecuteScenarioByName(String scenarioName, IEnumerable`1 parameters, Boolean useNoAuthProvider, CancellationToken token)
at CrmIntegration.CrmProcessor.ExecuteScenarioWithRetries(String scenarioId, Dictionary`2 parameters, CancellationToken token)
at CrmIntegration.CrmProcessor.ReportChat(ChatEndedEvent chatEndedEvent, CancellationToken token)


But so this exception is thrown *before* the API call is made.

Here is the exact config in the CRM Template, perhaps something is wrong there ?
Thanks in advance again for your precious help :)




<Scenario Id="ReportChat" Type="REST">
<Request SkipIf="[ReportChatEnabled]!=True" Url="https://3cx.nalios.be/3cx/chat/create" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
<PostValues Key="">
<Value Key="number" Passes="1" Type="String">[Number]</Value>
<Value Key="email" Passes="1" Type="String"></Value>
<Value Key="name" Passes="1" Type="String">[Name]</Value>
<Value Key="entitytype" Passes="1" Type="String">[EntityType]</Value>
<Value Key="messages" Passes="1" Type="String">[[ChatMessages].Replace("
","").Replace("
","&lt;br/&gt;").Replace("","")]</Value>
<Value Key="agent" Passes="1" Type="String">[Agent]</Value>
<Value Key="agentname" Passes="1" Type="String">[AgentFirstName] [AgentLastName]</Value>
<Value Key="duration" Passes="1" Type="String">[Duration]</Value>
<Value Key="date" Passes="1" Type="String">[DateTime]</Value>
<Value Key="subject" Passes="2" Type="String">[ChatSubject]</Value>
</PostValues>
</Request>
<Variables />
<Outputs AllowEmpty="false" />
</Scenario>
 
This is the problem:
<Value Key="messages" Passes="1" Type="String">[[ChatMessages].Replace(" ","").Replace(" ","&lt;br/&gt;").Replace("","")]</Value>

Try removing the final .Replace("",""), because the first argument can't be an empty string.
 
  • Like
  • Love
Reactions: Evolute IT and Lop
You're the man ! Godlike,
Full integration between CRM Template and Odoo done :)

Thanks a LOT sir.
 
  • Like
Reactions: jed and edossantos
@edossantos,

I still have one little question, but more practical, I think it's no bug.
When 3CX searches for a contact and don't find it, it creates it.
From the Create API, I do return the same data as the Search (with the ContactUrl).
Why wouldn't it open the ContactUrl after creation ? It's not much practical as the person getting the call then cannot update the caller's name etc. in Odoo (in this case).
Or it should and I'm missing something ?
I'm 100% sure I return the ContactUrl. And next calls do open the ContactUrl.
It also isn't cool because even if contact was created, the Call Log isn't sent after the call (while when the Search was OK, it does send the Call Log. But then we miss all Call Log for First Call of a customer).

If this is "normal", I'll then create the contact in the Search call if not found and return the data, so that 1/ the ContactUrl will open and 2/ The Call Log will be sent after the call :)

Thanks in advance for your insight,

Regards
 
Or it should and I'm missing something ?
It should be opened, actually the Web Client doesn't know if this contact was just created, or previously existed.... You should check if the Web Client is showing the contact details in this case, maybe you're not returning the correct data. Apart from the ContactUrl, you need to return as output the contact name, entity ID, entity type, and the phone number being searched.

It also isn't cool because even if contact was created, the Call Log isn't sent after the call (while when the Search was OK, it does send the Call Log. But then we miss all Call Log for First Call of a customer).
Looks like the returned contact is not being considered a match, otherwise the call should be logged as usual.


Finally, please note that in 3CX v18 Update 8 (still in beta), we're changing the way in which contacts are created. Since this update, contacts will not be created automatically anymore, and this will need to be triggered from the Web Client. You will need to create a scenario with id "CreateContactRecordFromClient", which is pretty much the same as the scenario you have with id "CreateContactRecord", but the difference is that you will have variables for the [FirstName], [LastName] and [Company].
 
  • Like
Reactions: Evolute IT
Alright thank you. You can perhaps tell me pretty fast then what's the error here.
I'm retuning this JSON from the CreateContact API Call:

{
'id': 52,
'name': 'New 3CX Contact +32476275584',
'company': 'N/A',
'email': False,
'phone': '32476275584',
'phone_1': '',
'mobile': '',
'mobile_1': '',
'show_url': 'https://3cx.nalios.be/web?#view_type=form&id=52&model=res.partner&action=56'
}

And here is my scenario definition in 3CX:
<Scenario Id="CreateContactRecord" Type="REST">
<Request SkipIf="[CreateContactEnabled]!=True||[IIf([CreateOnCallDirection]==Inbound,[CallDirection]!=Inbound,False)]==True" Url="https://3cx.nalios.be/3cx/contact/create" MessagePasses="0" RequestContentType="application/json" RequestEncoding="Json" RequestType="Post" ResponseType="Json">
<PostValues Key="">
<Value Key="number" Passes="1" Type="String">[Number]</Value>
<Value Key="firstname" Passes="2" Type="String">[CreateContactFirstName]</Value>
<Value Key="lastname" Passes="2" Type="String">[CreateContactLastName]</Value>
</PostValues>
</Request>
<Rules>
<Rule Type="Any">id</Rule>
</Rules>
<Variables>
<Variable Name="ContactID" Path="id">
<Filter />
</Variable>
<Variable Name="FirstName" Path="name">
<Filter />
</Variable>
<Variable Name="CompanyName" Path="company">
<Filter />
</Variable>
<Variable Name="Email" Path="email">
<Filter />
</Variable>
<Variable Name="PhoneBusiness" Path="phone">
<Filter />
</Variable>
<Variable Name="PhoneBusiness2" Path="phone_1">
<Filter />
</Variable>
<Variable Name="PhoneMobile" Path="mobile">
<Filter />
</Variable>
<Variable Name="PhoneMobile2" Path="mobile_1">
<Filter />
</Variable>
<Variable Name="ContactUrl" Path="show_url">
<Filter />
</Variable>
</Variables>
<Outputs AllowEmpty="false">
<Output Type="ContactID" Passes="0" Value="[ContactID]" />
<Output Type="FirstName" Passes="0" Value="[FirstName]" />
<Output Type="CompanyName" Passes="0" Value="[CompanyName]" />
<Output Type="Email" Passes="0" Value="" />
<Output Type="PhoneBusiness" Passes="0" Value="[PhoneBusiness]" />
<Output Type="PhoneBusiness2" Passes="0" Value="[PhoneBusiness2]" />
<Output Type="PhoneMobile" Passes="0" Value="[PhoneMobile]" />
<Output Type="PhoneMobile2" Passes="0" Value="[PhoneMobile2]" />
<Output Type="ContactUrl" Passes="0" Value="[ContactUrl]" />
<Output Type="EntityId" Passes="0" Value="[ContactID]" />
<Output Type="EntityType" Passes="0" Value="Contacts" />
</Outputs>
</Scenario>

Would it be because "email" is False ? Should I return an empty string instead perhaps ?

Thanks in advance
 
Would it be because "email" is False ? Should I return an empty string instead perhaps ?
I don't think so, even though your should set the output from the variable, as you're defining it:
<Output Type="Email" Passes="0" Value="[Email]" />

In any case, in order to understand what's going on, we will need the 3cxSystemService.log in verbose mode after reproducing the issue.
 
Got it, it was my fault, by checking the logs I saw my API was returning

'{"jsonrpc": "2.0", "id": null, "result": "<Response 244 bytes [200 OK]>"}'

instead of the Json dict.

Was my route expecting "json" while I should put "http" for this use case.

Thanks for your help, all good now :)

Regards
 
  • Like
Reactions: jed and edossantos
Sounds interesting!
Any chance you can share your code?
 
Hi @wieser ,
Unfortunately I cannot give the code, it's not opensource :)
The goal developing this module was to put it on the Odoo Apps store. You can find it there.
Regards
 
  • Like
Reactions: edossantos
Sounds interesting!
Any chance you can share your code?

Hi @wieser ,
Unfortunately I cannot give the code, it's not opensource :)
The goal developing this module was to put it on the Odoo Apps store. You can find it there.
Regards
And this is why our integration doesn't use an Odoo module but the API directly lol
 
  • Like
Reactions: edossantos
Very nice ! Looking at your website I don't find any information about an integration with Odoo :/
What would be the price of a full integration with the CRM Template ?
 
Very nice ! Looking at your website I don't find any information about an integration with Odoo :/
What would be the price of a full integration with the CRM Template ?
We don't sell it on our website. We're not an ecommerce.
 
  • Like
Reactions: edossantos and Lop
We don't sell it on our website. We're not an ecommerce.
Well can you provide any information about your integration, then?
Is it custom built? Or just built for a customer?
Or just built for own use?

Anyway, if you can share some insights or pointers (or even the source) that would be nice.

From 3CX's point of view the missing part is the REST API in Odoo. So I'm curious how you achieved integration from 3cx without that. There is also this, which seems to be licensed under GPL: https://apps.odoo.com/apps/modules/15.0/3cxcrm/
I have not tested that yet.
 
  • Like
Reactions: Lop
Status
Not open for further replies.

Forum statistics

Threads
112,314
Messages
591,847
Members
165,458
Latest member
Kayla Norris