-
Notifications
You must be signed in to change notification settings - Fork 16
Eh/odoo ticket integration #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
erichugy
wants to merge
29
commits into
master
Choose a base branch
from
eh/odoo-ticket-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
df68a52
Created initial odoo helpdesk typing and outline
erichugy 808d2b1
Created helpdesk and ticketing actions
erichugy 7e42bec
Bug: Force to requthenticate
erichugy bd436c4
Managed to get the helpdesk teams and keep session alive
erichugy be82415
Feat: Odoo Registration and Helpdesk Teams and Stages
erichugy 80e2f34
Creating customers
erichugy 9e78264
Update Odoo Helpdesk integration: bump package manager version, enhan…
erichugy 85f84c7
Fixed customer creation
erichugy 1271a7e
Completed Create ticket to a final working state
erichugy 866e692
Got Update to work
erichugy d62bd32
Added Readme for Odoo Helpdesk
erichugy 9a101ba
Fix: Formatting, Integration Version and Name, More Strict Types
erichugy 409f70b
Fix: Reverting root package.json updates
erichugy f30f9fe
Fix: Made version 1.0.0 and renamed integration name
erichugy caa22f2
Fix: Removed unused Priority Class. Forced OdooId to be a number. Mad…
erichugy 5c96ce1
Fix: Formatted with Prettier
erichugy 366b0ac
Chore: Added TTYL to cookie cache
erichugy 3d33904
Fix: Added copilot revisions
erichugy 122cd38
Updated Logo
erichugy 4ed650b
Fix: Removed `as unknown`, `as` casts when possible, Non-null asserti…
erichugy 5943d20
fix: Reverted integration definition for production
erichugy 570b103
Fix: Aligned customer schema with create customer function and schemas
erichugy ab5e093
Refactor: Update Odoo Helpdesk integration with new repository struct…
erichugy c72e19e
Chore: Removed unused logger parameter
erichugy 5d11fb3
Fix: Shortened hub.md
erichugy f220021
Fix: Applied prettier formatting
erichugy b5bdd68
Fix: Unregister the customerIdMapping in unregistration
erichugy 8947eee
Fix: removed unecessary comments. Removed `as` in helpdesk files and …
erichugy c139058
fix: Reverted integration definiition version and name for prodution …
erichugy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
integrations/odoo-helpdesk/definitions/actions/customers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| import { z, ActionDefinition } from '@botpress/sdk' | ||
| import { customerSchema, createCustomerPayloadSchema, createCustomerResultSchema } from 'definitions/schemas' | ||
|
|
||
| export const createCustomer: ActionDefinition = { | ||
| title: 'Create Customer', | ||
| description: 'Create a new customer', | ||
| input: { | ||
| schema: createCustomerPayloadSchema.extend({ | ||
| id: z.string().title('ID').describe('The id of the customer'), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| odooId: createCustomerResultSchema, | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchCustomerById: ActionDefinition = { | ||
| title: 'Fetch Customer By ID', | ||
| description: 'Fetch a customer by id', | ||
| input: { | ||
| schema: z.object({ | ||
| id: z.string().title('ID').describe('The id of the customer to fetch'), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| customer: customerSchema.title('Customer').describe('The fetched customer').optional(), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchCustomerByOdooId: ActionDefinition = { | ||
| title: 'Fetch Customer By Odoo ID', | ||
| description: 'Fetch a customer by odoo id', | ||
| input: { | ||
| schema: z.object({ | ||
| odooId: z.number().title('Odoo ID').describe('The odoo id of the customer to fetch'), | ||
| id: z | ||
| .string() | ||
| .title('ID') | ||
| .describe('The id of the customer to fetch. If provided, the returned customer will have this id.') | ||
| .optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| customer: customerSchema.title('Customer').describe('The fetched customer').optional(), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchCustomerByEmail: ActionDefinition = { | ||
| title: 'Fetch Customer By Email', | ||
| description: 'Fetch a customer by email', | ||
| input: { | ||
| schema: z.object({ | ||
| email: z.string().title('Email').describe('The email of the customer to fetch'), | ||
| id: z | ||
| .string() | ||
| .title('ID') | ||
| .describe('The id of the customer to fetch. If provided, the returned customer will have this id.') | ||
| .optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| customer: customerSchema.title('Customer').describe('The fetched customer').optional(), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const updateCustomerById: ActionDefinition = { | ||
| title: 'Update Customer', | ||
| description: 'Update a customer by id', | ||
| input: { | ||
| schema: z.object({ | ||
| id: z.string().title('ID').describe('The id of the customer to update'), | ||
| email: z.string().title('Email').describe('The new email of the customer').optional(), | ||
| name: z.string().title('Name').describe('The new name of the customer').optional(), | ||
| phone: z.string().title('Phone').describe('The new phone of the customer').optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| success: z.boolean().title('Success').describe('The success of the update'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const updateCustomerByOdooId: ActionDefinition = { | ||
| title: 'Update Customer By Odoo ID', | ||
| description: 'Update a customer by odoo id', | ||
| input: { | ||
| schema: z.object({ | ||
| odooId: z.number().title('Odoo ID').describe('The odoo id of the customer to update'), | ||
| email: z.string().title('Email').describe('The new email of the customer').optional(), | ||
| name: z.string().title('Name').describe('The new name of the customer').optional(), | ||
| phone: z.string().title('Phone').describe('The new phone of the customer').optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| success: z.boolean().title('Success').describe('The success of the update'), | ||
| }), | ||
|
Comment on lines
85
to
106
|
||
| }, | ||
| } | ||
|
|
||
| export const updateCustomerByEmail: ActionDefinition = { | ||
| title: 'Update Customer By Email', | ||
| description: 'Update a customer by email', | ||
| input: { | ||
| schema: z.object({ | ||
| email: z.string().title('Email').describe('The email of the customer to update'), | ||
| name: z.string().title('Name').describe('The new name of the customer').optional(), | ||
| phone: z.string().title('Phone').describe('The new phone of the customer').optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| success: z.boolean().title('Success').describe('The success of the update'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const actions = { | ||
| createCustomer, | ||
| fetchCustomerById, | ||
| fetchCustomerByEmail, | ||
| fetchCustomerByOdooId, | ||
| updateCustomerById, | ||
| updateCustomerByOdooId, | ||
| updateCustomerByEmail, | ||
| } as const | ||
35 changes: 35 additions & 0 deletions
35
integrations/odoo-helpdesk/definitions/actions/helpdesk.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { z, ActionDefinition } from '@botpress/sdk' | ||
| import { helpdeskTeamSchema, stageSchema } from 'definitions/schemas' | ||
|
|
||
| export const getHelpdeskTeams: ActionDefinition = { | ||
| title: 'Get Helpdesk Teams', | ||
| description: 'Get all helpdesk teams', | ||
| input: { | ||
| schema: z.object({}), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| helpdeskTeams: z.array(helpdeskTeamSchema).title('Helpdesk Teams').describe('The list of helpdesk teams'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const getStages: ActionDefinition = { | ||
| title: 'Get Stages', | ||
| description: 'Get all stages', | ||
| input: { | ||
| schema: z.object({ | ||
| teamId: z.number().optional().title('Team ID').describe('The id of the team to get the stages for'), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| stages: z.array(stageSchema).title('Stages').describe('The list of stages'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const actions = { | ||
| getHelpdeskTeams, | ||
| getStages, | ||
| } as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import * as sdk from '@botpress/sdk' | ||
erichugy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { actions as customerActions } from './customers' | ||
| import { actions as ticketsActions } from './tickets' | ||
| import { actions as helpdeskActions } from './helpdesk' | ||
|
|
||
| export const actions = { | ||
| ...customerActions, | ||
| ...ticketsActions, | ||
| ...helpdeskActions, | ||
| } as const satisfies sdk.IntegrationDefinitionProps['actions'] | ||
119 changes: 119 additions & 0 deletions
119
integrations/odoo-helpdesk/definitions/actions/tickets.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import { z, ActionDefinition } from '@botpress/sdk' | ||
| import { ticketSchema } from 'definitions/schemas' | ||
|
|
||
| export const createTicket: ActionDefinition = { | ||
| title: 'Create Ticket', | ||
| description: 'Create a new ticket', | ||
| input: { | ||
| schema: z.object({ | ||
| name: z.string().title('Name').describe('The name of the ticket'), | ||
| description: z.string().title('Description').describe('The description of the ticket'), | ||
| teamId: z.number().min(1).title('Team ID').describe('The helpdesk team ID associated with the ticket'), | ||
| priority: z | ||
| .enum(['0', '1', '2', '3']) | ||
| .title('Priority') | ||
| .describe('The priority of the ticket (0 is the lowest priority)') | ||
| .optional(), | ||
| customerOdooId: z.number().title('Customer Odoo ID').describe('The Odoo customer ID associated with the ticket'), | ||
| stageId: z.number().optional().title('Stage ID').describe('The stage ID associated with the ticket'), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| ticketId: z.number().title('Ticket ID').describe('The ID of the created ticket'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchTicketById: ActionDefinition = { | ||
| title: 'Fetch Ticket', | ||
| description: 'Fetch a ticket by id', | ||
| input: { | ||
| schema: z.object({ | ||
| id: z.number().title('Ticket ID').describe('The id of the ticket to fetch'), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| ticket: ticketSchema.title('Ticket').describe('The fetched ticket').optional(), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchTicketsByCustomerId: ActionDefinition = { | ||
| title: 'Fetch Tickets by Customer', | ||
| description: 'Fetch all tickets by customer', | ||
| input: { | ||
| schema: z.object({ | ||
| customerOdooId: z.number().title('Customer Odoo ID').describe('The Odoo customer ID associated with the ticket'), | ||
| page: z.number().title('Page').describe('The page of the tickets to fetch').min(1).default(1).optional(), | ||
| pageSize: z | ||
| .number() | ||
| .min(1) | ||
| .title('Page Size') | ||
| .describe('The number of tickets to fetch per page') | ||
| .default(100) | ||
| .optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| tickets: z.array(ticketSchema).title('Tickets').describe('The list of tickets associated with the customer'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const fetchTicketsByCustomerEmail: ActionDefinition = { | ||
| title: 'Fetch Tickets by Customer Email', | ||
| description: 'Fetch all tickets by customer email', | ||
| input: { | ||
| schema: z.object({ | ||
| customerEmail: z.string().title('Customer Email').describe('The email of the customer'), | ||
| page: z.number().title('Page').describe('The page of the tickets to fetch').min(1).default(1).optional(), | ||
| pageSize: z | ||
| .number() | ||
| .min(1) | ||
| .title('Page Size') | ||
| .describe('The number of tickets to fetch per page') | ||
| .default(100) | ||
| .optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| tickets: z.array(ticketSchema).title('Tickets').describe('The list of tickets associated with the customer'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const updateTicket: ActionDefinition = { | ||
| title: 'Update Ticket', | ||
| description: 'Update a ticket by id', | ||
| input: { | ||
| schema: z.object({ | ||
| ticketId: z.number().title('Ticket ID').describe('The ID of the ticket to update'), | ||
| name: z.string().title('Name').describe('The name of the ticket').optional(), | ||
| description: z.string().title('Description').describe('The description of the ticket').optional(), | ||
| teamId: z.number().min(1).title('Team ID').describe('The helpdesk team ID associated with the ticket').optional(), | ||
| priority: z | ||
| .enum(['0', '1', '2', '3']) | ||
| .title('Priority') | ||
| .describe('The priority of the ticket (0 is the lowest priority, 3 is the highest)') | ||
| .optional(), | ||
| stageId: z.number().title('Stage ID').describe('The stage ID associated with the ticket').optional(), | ||
| }), | ||
| }, | ||
| output: { | ||
| schema: z.object({ | ||
| success: z.boolean().title('Success').describe('The success of the update'), | ||
| }), | ||
| }, | ||
| } | ||
|
|
||
| export const actions = { | ||
| createTicket, | ||
| fetchTicketById, | ||
| fetchTicketsByCustomerId, | ||
| fetchTicketsByCustomerEmail, | ||
| updateTicket, | ||
| } as const |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| import { actions } from './actions' | ||
| import { states } from './states' | ||
|
|
||
| export { actions, states } |
54 changes: 54 additions & 0 deletions
54
integrations/odoo-helpdesk/definitions/schemas/authentication.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { z } from '@botpress/sdk' | ||
|
|
||
| const authPayloadBodySchema = z.object({ | ||
| jsonrpc: z.literal('2.0'), | ||
| params: z.object({ | ||
| db: z.string().describe('The Odoo database name (Case sensitive).'), | ||
| login: z.string().describe('The Odoo email address.'), | ||
| password: z.string().describe('The Odoo password.').secret(), | ||
| }), | ||
| id: z.number().describe('The ID of the request'), | ||
| }) | ||
|
|
||
| const authHeadersSchema = z.object({ | ||
| 'Content-Type': z.literal('application/json'), | ||
| }) | ||
|
|
||
| /** | ||
| * Schema for authentication response headers. | ||
| * Used to type the headers from axios responses. | ||
| */ | ||
| const authResponseHeadersSchema = z.object({ | ||
| 'set-cookie': z | ||
| .union([z.string(), z.array(z.string())]) | ||
| .optional() | ||
| .describe('The set-cookie header from the Odoo API response.'), | ||
| }) | ||
|
|
||
| const cookieSchema = z.object({ | ||
| cookie: z.string().describe('The cookie to use for the Odoo API'), | ||
| timestamp: z.number().describe('The timestamp of the cookie'), | ||
| }) | ||
|
|
||
| export const authResponseDataSchema = z.object({ | ||
| jsonrpc: z.literal('2.0'), | ||
| result: z | ||
| .object({ | ||
| uid: z.number(), | ||
| }) | ||
| .optional(), | ||
| error: z | ||
| .object({ | ||
| code: z.number(), | ||
| message: z.string(), | ||
| data: z.unknown().optional(), | ||
| }) | ||
| .optional(), | ||
| id: z.number(), | ||
| }) | ||
|
|
||
| export type AuthPayloadBody = z.infer<typeof authPayloadBodySchema> | ||
| export type AuthHeaders = z.infer<typeof authHeadersSchema> | ||
| export type AuthResponseHeaders = z.infer<typeof authResponseHeadersSchema> | ||
| export type Cookie = z.infer<typeof cookieSchema> | ||
| export type AuthResponseData = z.infer<typeof authResponseDataSchema> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.